<html>
<head>
<link rel='stylesheet' href='../../../../../../../../../../../../../js/sh/SyntaxHighlighter.css' type='text/css' />
<script src='../../../../../../../../../../../../../js/sh/shCore.js'></script>
<script src='../../../../../../../../../../../../../js/sh/shBrushJava.js'></script>
<style>
* {
font-family:Courier New,monospace;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  font-size: 11px;
}
.dp-highlighter {
  white-space: nowrap;
  overflow: visible;
  width: 600px;
  font-size: 11px;
  font-family:Courier New,monospace;
}
</style>
</head>
<body>
<textarea name='code' class='java:nogutter' rows='15' cols='120'>
isc.DataSource.create({
    ID: "users",
    dataFormat: "xml",
    dataURL: "/isomorphic/system/reference/inlineExamples/dataIntegration/xml/serverValidationErrors/serverResponse.xml",
    fields: [
        {name: "userName", title: "Username", type: "text", required: true, length: 50},
        {name: "firstName", title: "First Name", type: "text", required: true, length: 50},
        {name: "lastName", title: "Last Name", type: "text", required: true, length: 50},
        {name: "email", title: "Email", type: "text", required: true, length: 100},
        {name: "password", title: "Password", type: "password", required: true, length: 20}
    ],
    transformResponse : function (dsResponse, dsRequest, xmlData) {
        var status = isc.XMLTools.selectString(xmlData, "/response/status");
        if (status != "success") {
            dsResponse.status = isc.RPCResponse.STATUS_VALIDATION_ERROR;
            var errors = isc.XMLTools.selectNodes(xmlData, "/response/errors");
            dsResponse.errors = isc.XMLTools.toJS(errors);
        }
    }
});

isc.DynamicForm.create({
    ID: "boundForm",
    dataSource: "users",
    values : {
        userName: "bsmith",
        firstName: "Bob",
        lastName: "Smith",
        email: "bob@smith.com",
        password: "sekrit"
    }
});

isc.VLayout.create({
    members: [
        boundForm,
        isc.IButton.create({
            title: "Save",
            click : function () {
                if (boundForm.validate()) boundForm.saveData();
            }
        })
    ]
});
</textarea>
<script class='javascript'>
dp.SyntaxHighlighter.HighlightAll("code");
</script>
</body>
</html>
